home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d17 / printq11.arc / PRINTQ.C < prev    next >
C/C++ Source or Header  |  1987-03-21  |  10KB  |  191 lines

  1. /****************************************************************************/
  2. /* PQ.C --- Support Routines for PRINT.COM Multiplex Interrupt              */
  3. /****************************************************************************/
  4. /* These routines provide support for the print queue multiplex interrupt.  */
  5. /* They are for use with Microsoft C v4.0.  The routines are:               */
  6. /*                                                                          */
  7. /* PrintInstalled --- See if PRINT.COM is installed (Fn 0).                 */
  8. /* PrintSubmit    --- Submit a file to the print queue (Fn 1).              */
  9. /* PrintCancel    --- Cancel file(s) from the print queue (Fn 2).           */
  10. /* PrintCancelAll --- Cancel all files from the print queue (Fn 3).         */
  11. /* PrintStatus    --- Freeze queue and get pointer to queue list (Fn 4).    */
  12. /* PrintStatusEnd --- Unfreeze queue.                                       */
  13. /*                                                                          */
  14. /* Notes:                                                                   */
  15. /*    1.  Compile with /Zp switch.  Otherwise, the struct "packet" in       */
  16. /*        PrintSubmit will have an extra byte added between "level" and     */
  17. /*        "file".                                                           */
  18. /****************************************************************************/
  19.  
  20. #include <dos.h>
  21. #include <stdlib.h>
  22.  
  23.  
  24. /****************************************************************************/
  25. /* PrintInstalled --- See if PRINT.COM is installed (Fn 0).                 */
  26. /*--------------------------------------------------------------------------*/
  27. /*    This routine checks to see if PRINT.COM is Installed by calling the   */
  28. /* Multiplex Interrupt (0x2F).  If it is, TRUE is returned; otherwise,      */
  29. /* FALSE is returned.                                                       */
  30. /*    PRINT.COM is multiplex number 1.  The Get Installed State is function */
  31. /* number 0.  After the interrupt, AL is 0xFF if PRINT.COM is Installed.    */
  32. /*                                                                          */
  33. /* Parameters:                                                              */
  34. /*    None.                                                                 */
  35. /*                                                                          */
  36. /* Returns:                                                                 */
  37. /*    TRUE or FALSE indicating if PRINT.COM is Installed.                   */
  38. /****************************************************************************/
  39.  
  40. int PrintInstalled ()
  41. {
  42.     union REGS regs;
  43.  
  44.     regs.x.ax = 0x0100;
  45.     int86 (0x2F, ®s, ®s);
  46.     return (regs.h.al == 0xFF);
  47.  
  48. } /* end PrintInstalled */;
  49.  
  50.  
  51. /****************************************************************************/
  52. /* PrintSubmit    --- Submit a file to the print queue (Fn 1).              */
  53. /*--------------------------------------------------------------------------*/
  54. /*    Queue a file to be printed.  Return the error code.  The file must    */
  55. /* consist of a drive designator, full path, and full name.  file names     */
  56. /* containing wild card characters are not allowed.                         */
  57. /*                                                                          */
  58. /* Parameters:                                                              */
  59. /*    File --- Pointer to string containing name to be queued.              */
  60. /*                                                                          */
  61. /* Returns:                                                                 */
  62. /*    Status:  0 == No error, file queued.                                  */
  63. /*             2 == File not found.                                         */
  64. /*             3 == Path not found.                                         */
  65. /*             4 == Too many open files.                                    */
  66. /*             5 == Access Denied.                                          */
  67. /*             8 == Queue Full.                                             */
  68. /*             9 == Busy.                                                   */
  69. /*            12 == Name too long.                                          */
  70. /*            15 == Invalid Drive.                                          */
  71. /****************************************************************************/
  72.  
  73. int PrintSubmit (File)
  74. char *File;
  75. {
  76.     union REGS regs;
  77.     struct {
  78.         char level;
  79.         char far *file;
  80.     } packet;
  81.  
  82.     packet.level = 0;
  83.     packet.file  = (char far *) File;
  84.     regs.x.ax = 0x0101;
  85.     regs.x.dx = (unsigned) &packet;
  86.     int86 (0x2F, ®s, ®s);
  87.     return (regs.x.ax > 15) ? (0) : (regs.x.ax);
  88.  
  89. } /* end PrintSubmit */
  90.  
  91.  
  92. /****************************************************************************/
  93. /* PrintCancel    --- Cancel file(s) from the print queue (Fn 2).           */
  94. /*--------------------------------------------------------------------------*/
  95. /*    Cancel one or more files from the queue.  File names containing wild  */
  96. /* card characters are allowed.                                             */
  97. /*                                                                          */
  98. /* Parameters:                                                              */
  99. /*    File --- Pointer to string containing name to be queued.              */
  100. /*                                                                          */
  101. /* Returns:                                                                 */
  102. /*    Nothing.                                                              */
  103. /****************************************************************************/
  104.  
  105. void PrintCancel (File)
  106. char *File;
  107. {
  108.     union REGS regs;
  109.  
  110.     regs.x.ax = 0x0102;
  111.     regs.x.dx = (unsigned) File;
  112.     int86 (0x2F, ®s, ®s);
  113.  
  114. } /* end PrintCancel */
  115.  
  116.  
  117. /****************************************************************************/
  118. /* PrintCancelAll --- Cancel all files from the print queue (Fn 3).         */
  119. /*--------------------------------------------------------------------------*/
  120. /*    Cancel printing of all files currently in the print queue.            */
  121. /*                                                                          */
  122. /* Parameters:                                                              */
  123. /*    None.                                                                 */
  124. /*                                                                          */
  125. /* Returns:                                                                 */
  126. /*    Nothing.                                                              */
  127. /****************************************************************************/
  128.  
  129. void PrintCancelAll ()
  130. {
  131.     union REGS regs;
  132.  
  133.     regs.x.ax = 0x0103;
  134.     int86 (0x2F, ®s, ®s);
  135.  
  136. } /* end PrintCancelAll */
  137.  
  138.  
  139. /****************************************************************************/
  140. /* PrintStatus    --- Freeze Queue and Get Status (Fn 4).                   */
  141. /*--------------------------------------------------------------------------*/
  142. /*    Freeze the print queue and return a pointer to the queue list and the */
  143. /* number of errors encountered trying to write the last char to the print  */
  144. /* device.                                                                  */
  145. /*                                                                          */
  146. /* Parameters:                                                              */
  147. /*    ErrCnt   --- Pointer to an integer in which to store error count.     */
  148. /*    QueuePtr --- Pointer to a far pointer to char in which to store the   */
  149. /*                 address of the print queue.                              */
  150. /*                                                                          */
  151. /* Returns:                                                                 */
  152. /*    Nothing.                                                              */
  153. /****************************************************************************/
  154.  
  155. void PrintStatus (QueuePtr, ErrCnt)
  156. char     *far*QueuePtr;
  157. unsigned *ErrCnt;
  158. {
  159.     union  REGS  regs;
  160.     struct SREGS sregs;
  161.  
  162.     regs.x.ax = 0x0104;
  163.     int86x (0x2F, ®s, ®s, &sregs);
  164.     *ErrCnt   = regs.x.dx;
  165.     FP_SEG(*QueuePtr) = sregs.ds;
  166.     FP_OFF(*QueuePtr) = regs.x.si;
  167.  
  168. } /* end PrintStatusEnd */
  169.  
  170.  
  171. /****************************************************************************/
  172. /* PrintStatusEnd --- Unfreeze queue and get error code (Fn 5).             */
  173. /*--------------------------------------------------------------------------*/
  174. /*    Release the queue from PrintStatus (Fn 4) and return the status.      */
  175. /*                                                                          */
  176. /* Parameters:                                                              */
  177. /*    None.                                                                 */
  178. /*                                                                          */
  179. /* Returns:                                                                 */
  180. /*    Nothing.                                                              */
  181. /****************************************************************************/
  182.  
  183. void PrintStatusEnd ()
  184. {
  185.     union REGS regs;
  186.  
  187.     regs.x.ax = 0x0105;
  188.     int86 (0x2F, ®s, ®s);
  189.  
  190. } /* end PrintStatusEnd */
  191.